package smcms.service.product.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import smcms.commons.api.entity.result.CommonsResult;
import smcms.service.product.entity.*;
import smcms.service.product.service.ProductService;

import java.util.List;

@RestController
@RequestMapping("/ProductController")
public class ProductController {

    @Autowired
    private CommonsResult commonsResult;
    @Autowired
    private ProductService productService;

    @PostMapping("/insertProduct")
    public CommonsResult insertProduct(@RequestBody ProductReq productReq){
        CommonsResult commonsResult = productService.insertProduct(productReq);
        return commonsResult;
    }
    @PostMapping("/updateProduct")
    public CommonsResult updateProduct(@RequestBody ProductReq productReq){
        CommonsResult commonsResult = productService.updateProduct(productReq);
        return commonsResult;
    }
    @PostMapping("/deleteProduct")
    public CommonsResult deleteProduct(@RequestBody ProductReq productReq){
        CommonsResult commonsResult = productService.deleteProduct(productReq);
        return commonsResult;
    }
    @PostMapping("/queryProductList")
    public CommonsResult queryProductList(@RequestBody ProductReq productReq){
        List<ProductResp> productResps = productService.queryProductList(productReq);
        return commonsResult.success(productResps);
    }
    @PostMapping("/queryProduct")
    public CommonsResult queryProduct(@RequestBody ProductReq productReq){
        ProductResp productResp = productService.queryProduct(productReq);
        return commonsResult.success(productResp);
    }

    @PostMapping("/productInventoryPlus")
    public CommonsResult productInventoryPlus(@RequestBody InventoryPlus req){
        CommonsResult commonsResult = productService.productInventoryPlus(req);
        return commonsResult;
    }

    @PostMapping("queryProductExport")
    List<ProductTemp> queryProductExport(@RequestBody ProductReq productReq) {
        List<ProductTemp> productTemps = productService.queryProductExport(productReq);
        return productTemps;
    }

    @PostMapping("queryProductType")
    CommonsResult queryProductType(@RequestBody ProductReq productReq) {
        List<CategoryResp> categoryRespList = productService.queryProductType(productReq);
        return commonsResult.success(categoryRespList);
    }
}
